//
//  OosUser.m
//  Oos4ios
//
//  Created by Pablo Gonzalez on 3/21/11.
//  Copyright 2011 11870.com. All rights reserved.
//

#import <oos4ios/Model/OosUser.h>
#import <oos4ios/Model/OosMe.h>


@implementation OosUser

@dynamic nick;
@dynamic avatar;
@dynamic slug;
@dynamic webUrlString;
@dynamic userTags;
@dynamic userLists;
@dynamic services;
@dynamic reviews;
//@dynamic contacts;

@dynamic updatedActivities;
@dynamic updatedCheckins;
@dynamic updatedReviews;
@dynamic updatedServices;
@dynamic updatedContacts;

@dynamic contacts;

static NSString *fetchPredicate = @"slug = %@";

+ (OosUser *) userFromSlug:(NSString *)slug
{
    
    OosUser *result = [super objectWithPredicate: fetchPredicate, slug];
    
    if (!result) {
        result = [super create];
        result.slug = slug;
    }
	return result;
}

- (NSURL *)webUrl
{
    NSString *url = [self webUrlString];
    if (url) {
        return [NSURL URLWithString:url];
    } else {
        return nil;
    }
}

- (void)setWebUrl:(NSURL *)url
{
    if (!url) {
        self.webUrlString = nil;
    } else {
        self.webUrlString = url.absoluteString;
    }
}

- (BOOL)isLogged
{
    return [self isKindOfClass: [OosMe class]];
}

@end
